<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <base href="<?php echo site_url()?>" />
        <link rel="stylesheet" href="<?php echo site_url()?>assets/css/style.default.css" type="text/css" />
        <link rel="stylesheet" href="<?php echo site_url()?>assets/css/font-awesome.css" type="text/css" />
        <script type="text/javascript" src="<?php echo site_url()?>assets/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo site_url()?>assets/js/custom.js"></script>
        <style>
            .closepopup{
                position: fixed;
                top: 0;
                right: 0;
                width: 40px;
                height: 38px;
                background-color: rgba(225,102,0,.6);
                border-bottom-left-radius: 50% !important;
                border-bottom-right-radius: 5% !important;
                border-top-left-radius: 5% !important;
                border-top-right-radius: 0 !important;
                border-radius: 50%;
                border: 0;
                line-height: 1;
                font-size: 18px;
                cursor: pointer;
                z-index: 99999;
            }
            
            .table tr td:first-child{
                text-align: left;
            }
            tr:nth-child(odd) td:nth-last-child(4)
            {
                background-color: transparent;
            }
            tr:nth-child(even) td:nth-last-child(4)
            {
                background-color: transparent;
            }
        </style>
    </head>
    <body>
        <button class="closepopup" onclick="closeIframe()"><i class="fa fa-times"></i></button>
        <div class="pageheader">
                    <ul class="hornav">
                        <li class="current" style="width:  200px;"><a href="#updates">Báo cáo</a></li>
                    </ul>
        </div><!--pageheader-->
        
        <div id="contentwrapper" class="contentwrapper">
        	<div id="updates" class="subcontent">
                    <div class="two_third content_left" style="width: 98%">
                    <div class="tableoptions" style="padding: 55px 15px 15px; box-sizing: border-box;">
                        <span onclick="exportToExcel()" id="addCategories" class="submit radius2">Xuất file excel</span>
                        <span onclick="exportToDoc()" id="addCategories" class="submit radius2">Xuất file word</span>
                        <span onclick="closeIframe()" id="addCategories" class="submit radius2">Hủy bỏ</span>                        
                    </div>
                    <div id="boxTool">
                    
                    
                    
                    </div>
                    <div class="span-full" id="page">
                        <div class="block" style="border-radius: 5px">                        
                           <div class="block-fluid" id="page_show" style="padding-bottom: 30px;">
                                <table cellpadding="0" cellspacing="0" width="100%" id="Categrories" class="table stdtable stdtablecb" style="margin: 0">
                                    <thead>
                        				<tr>
                        					<th>Cửa hàng</th>
                                            <th>Số thiết bị</th>
                        					<th>MAC</th>
                        					<th>NASID</th>
                        					<th>Online gần nhất</th>
                                            <th>Trạng thái</th>
                        				</tr>
                        			</thead>
                                    <tbody>
                                    <?php foreach($data AS $key => $value):?>
                                    <?php if($value->count_device > 1):?>
                                        <?php $i = 1; foreach($value->device AS $dkey => $dval):?>
                                        <?php if($i === 1):?>
                                        <tr>
                                    		<td style="width: 33%;" rowspan="<?php echo $value->count_device?>"><?php echo str_replace("'", "&apos;", stripslashes($value->address.', '.$value->district.', '.$value->province))?></td>
                                            <td rowspan="<?php echo $value->count_device?>"><?php echo $value->count_device?></td>
                                            <td><?php echo $dval->mac?></td>
                                            <td><?php echo $dval->nasid?></td>
                                            <td><?php echo date('H:i:s d-m-Y',$dval->timeupdate)?></td>
                                            <td><?php if((time()- $dval->time_update) >= 300):?>
                                                    <span style="color:  #ff0000;">Offline</span>
                                                <?php else:?>
                                                    <span style="color:  #0000ff;">Online</span>
                                                <?php endif;?>
                                            </td>
                                    	</tr>
                                        <?php else:?>
                                        <tr>
                                            <td><?php echo $dval->mac?></td>
                                            <td><?php echo $dval->nasid?></td>
                                            <td><?php echo date('H:i:s d-m-Y',$dval->timeupdate)?></td>
                                            <td><?php if((time()- $dval->time_update) >= 300):?>
                                                    <span style="color:  #ff0000;">Offline</span>
                                                <?php else:?>
                                                    <span style="color:  #0000ff;">Online</span>
                                                <?php endif;?>
                                            </td>
                                    	</tr>
                                        <?php endif;?>
                                        <?php $i++; endforeach;?>
                                    <?php else:?>
                                        <tr>
                                    		<td style="width: 33%;"><?php echo str_replace("'", "&apos;", stripslashes($value->address.', '.$value->district.', '.$value->province))?></td>
                                            <td><?php echo $value->count_device?></td>
                                            <td><?php echo $value->device[0]->mac?></td>
                                            <td><?php echo $value->device[0]->nasid?></td>
                                            <td><?php echo date('H:i:s d-m-Y',$value->device[0]->timeupdate)?></td>
                                            <td><?php if((time()- $value->device[0]->time_update) >= 300):?>
                                                    <span style="color:  #ff0000;">Offline</span>
                                                <?php else:?>
                                                    <span style="color:  #0000ff;">Online</span>
                                                <?php endif;?>
                                            </td>
                                    	</tr>
                                    <?php endif;?>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                            </div> 
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="orverlay">
            <div class="box_orverlay">
                Đang xuất file...
            </div>
        </div>
        <style>
        .orverlay{
            left: 0px;float: left;width: 100%;background: rgba(0,0,0,.4); height: 100%;position: fixed;top: 0;z-index: 99999999;overflow: auto;box-sizing: border-box;display: none;padding-top:15%
        }
        .orverlay .box_orverlay{
            margin: 60px auto;width: 110px;background: #FFF;font-size: 15px;color: #666;padding: 10px;
        }
        .orverlay .box_orverlay h2{
            float: left;width: 100%;margin-top: -3px;background: orange;color: #fff;font-weight: normal;
        }
        .orverlay .box_orverlay p{
            padding: 5px 10px
        }
        </style>
    </body>
</html>